﻿<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Pragma" content="no-cache">
<meta name="GENERATOR" content="Microsoft FrontPage 12.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel="STYLESHEET" type="text/css" id="SkinStyleSheet">
<title>WebNoteEditor</title>
<style>
#inputAttachFile{
	width:100%;
}
</style>
<script language="javascript" type="text/javascript" src="../script/windialog.js"></script>

<script language="javascript">
window.onload=function()
{
	EditorWindow.renderWindowAsIE(window);
	AutoResizeDialogWindow();
}
function __btnOk_onclick()
{
	//alert(document.getElementById("inputAttachFile").value);
	if (document.getElementById("inputAttachFile").value.toString().replace(/(^\s*)|(\s*$)/g, "")=="")
	{
		alert(EditorWindow.lang_tips_selectattachfile);
		return;
	}
	var extName=EditorWindow.getFileExt(document.getElementById("inputAttachFile").value);
	if (!EditorWindow.$config.allow_upload_file_ext.isInArray(extName))
	{
		alert(EditorWindow.lang_tips_attachfileformaterror);
		return;
	}
	if (EditorWindow.$browser.isIE)
	{
		if (EditorWindow.$config.ActiveX)
		{
			if (EditorWindow.ActivexSetuped)
			{
				var el=new ActiveXObject("WebNote_PowerUpload.PowerUpload");
				el.pagesize=EditorWindow.$config.ATupload_pagesize;
				if(el.getFileInfo(getPath(document.getElementById("inputAttachFile"))))
				{
					if(parseInt(el.FileSize)>EditorWindow.$config.ATupload_maxfilesize && EditorWindow.$config.ATupload_maxfilesize>0)
					{
						alert(EditorWindow.lang_upload_largerthanmax+":"+EditorWindow.FileSizeToString(EditorWindow.$config.ATupload_maxfilesize));
						el=null;
						return;
					}
				}
				el=null;
			}
		}
	}
	var sHTML="<div class=\"WebNoteEditor_AttachFileArea "+extName+"\"><a href=\""+getPath(document.getElementById("inputAttachFile"))+"\" class=\"WebNoteEditor_AttachFile\" target=\"_blank\">"+EditorWindow.getFileName(document.getElementById("inputAttachFile").value)+"</a></div><p></p>"
	//var sHTML="<div class=\"WebNoteEditor_AttachFileArea\"><img src=\"images/filetype/"+extName+".gif\" class=\"WebNoteEditor_Img_FileType\" webnoteeditor=\"true\"><a href=\""+document.getElementById("inputAttachFile").value+"\" class=\"WebNoteEditor_AttachFile\" target=\"_blank\">"+EditorWindow.getFileName(document.getElementById("inputAttachFile").value)+"</a></div>"
	EditorWindow.pasteHTML(sHTML);

	window.close();
}


function __btnCancel_onclick()
{
	window.close();
}

function getPath(obj)
{
	if(obj)
	{
		try
		{
			if (window.navigator.userAgent.indexOf("MSIE")>=1)
			{
				obj.select();
	
				return document.selection.createRange().text;
				
			}
			else if(window.navigator.userAgent.indexOf("Firefox")>=1)
			{
				if(obj.files)
				{
					return obj.files.item(0).getAsDataURL();
				}
				return obj.value;
			}
			return obj.value;
		}
		catch(e)
		{
			return obj.value;
		}
	}
}  
</script>
</head>

<body class="dialog">
<script language="javascript" type="text/javascript">dialogTitle("lang_insertattachfile");</script>

<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
	    <input type="file" id="inputAttachFile" class="dialogInput">
    </td>
  </tr>
  <tr>
    <td class="hr">
		<hr size="1" color="#B3AC9D">
    </td>
  </tr>
  <tr>
    <td style="color:#0000FF"><script language="javascript">dialogPrintlang("lang_tips_attachfileformat");document.write(EditorWindow.$config.allow_upload_file_ext);</script>
    </td>
  </tr>
  <tr>
    <td align="right" class="hr">
    	<script language="javascript" type="text/javascript">
    		PrintButtons2();
    	</script>
    </td>
  </tr>
</table>
</body>

</html>
